package com.friend.joey.applicationfriend.Adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.friend.joey.applicationfriend.Classes.FriendItem;
import com.friend.joey.applicationfriend.R;

import java.util.List;

/**
 * Created by Joey on 2017/4/27.
 */

public class FriendAdapter extends RecyclerView.Adapter<FriendAdapter.ViewHolder> {

    private List<FriendItem> MsgList;


    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView txtname;
        TextView txtsign;
        public ViewHolder(View view){
            super(view);
            txtname=(TextView)view.findViewById(R.id.txt_friendname);
            txtsign=(TextView)view.findViewById(R.id.txt_friendsign);
        }
    }

    public FriendAdapter(List<FriendItem> msgList){
        MsgList = msgList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fefriend_item,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        FriendItem msg = MsgList.get(position);
        holder.txtname.setText(msg.getFriendName());
        holder.txtsign.setText(msg.getFriendSign());
    }

    @Override
    public int getItemCount() {
        return MsgList.size();
    }
}
